package com.mm.cme.kotlin_001.level02.i_002_branch_expression

import com.mm.cme.kotlin_001.utils.pl

/**
 * Descriptions：when表达式
 * <p>
 * Author：ChenME
 * Date：2017/7/16
 * Email：ibelieve1210@163.com
 */
fun main(args: Array<String>) {
    val result = fun() = 3 + 2
    val x = 5
    when (x) {
        is Int -> pl("$x is Int.")
        in 1..100 -> pl("$x is between 1 and 100.")
        !in 1..100 -> pl("$x is not between 1 and 100.")
        result() -> pl("$x is == result")
    }

    val mode = when {
        args.isNotEmpty() && args[0] == "1" -> 1
        else -> 0
    }
}